package com.kust.smarhome.background.mapper;

import com.github.yulichang.base.MPJBaseMapper;
import com.kust.smarhome.background.common.dto.OrderFormInfoDto;
import com.kust.smarhome.background.model.OrderForm;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author iAuzre
 * @since 2021-07-31
 */
@Repository
public interface OrderFormMapper extends MPJBaseMapper<OrderForm> {

    /*id username money address created state*/

    @Select("select o.id,u.username,o.money,o.address_id as address,o.created,o.state " +
            "from order_form o " +
            "left join user u " +
            "on o.user_id=u.id " +
            "where o.id like concat('%',#{id},'%')")
    List<OrderFormInfoDto> getDto(String id);

    @Select("select o.id,u.username,o.money,o.address_id as address,o.created,o.state " +
            "from order_form o " +
            "left join user u " +
            "on o.user_id=u.id " +
            "where o.id like concat('%',#{id},'%') " +
            "and o.state=#{state}")
    List<OrderFormInfoDto> getDtoByState(String id, Integer state);
}
